<template>
  <div>
    <el-card>
      <div slot="header">
        <!-- 头部 -->
        <div class="category-header">
          <span>销售额类别占比</span>
          <el-radio-group v-model="radio">
            <el-radio-button label="全部渠道"></el-radio-button>
            <el-radio-button label="线上"></el-radio-button>
            <el-radio-button label="门店"></el-radio-button>
          </el-radio-group>
        </div>
      </div>
      <!-- 尾部 -->
      <div>
        <!-- 饼图 -->
        <div class="charts" ref="charts"></div>
      </div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  name: 'Category',
  data() {
    return {
      radio: '线上'
    }
  },
  mounted() {
    let MyEcharts = echarts.init(this.$refs.charts)
    MyEcharts.setOption({
      tooltip: {
        trigger: 'item'
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: '50%',
          data: [
            { value: 1048, name: 'Search Engine' },
            { value: 735, name: 'Direct' },
            { value: 580, name: 'Email' },
            { value: 484, name: 'Union Ads' },
            { value: 300, name: 'Video Ads' }
          ],
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }
      ]
    })
  }
}
</script>

<style scoped>
.category-header {
  display: flex;
  justify-content: space-between;
}

.charts{
  width:100%;
  height:265px;
}
</style>